package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TAcadeAchiveInfoTemp;
import cn.com.headfree.mouldshow.dao.TAcadeAchiveInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tAcadeAchiveInfoTempDao")
public class TAcadeAchiveInfoTempDaoImpl extends BaseDaoImpl<TAcadeAchiveInfoTemp> implements TAcadeAchiveInfoTempDao {


    @Override
    public void saveInfo(TAcadeAchiveInfoTemp tAcadeAchiveInfo) {
        String sql = "insert into t_acade_achive_info_temp (id,pub_time,acad_type,acad_name,summary,pub_name,issn,periodic_no,page,publisher,level,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{pub_time,jdbcType=DATE},")
                .append("#{acad_type,jdbcType=VARCHAR},").append("#{acad_name,jdbcType=VARCHAR},")
                .append("#{summary,jdbcType=VARCHAR},").append("#{pub_name,jdbcType=VARCHAR},")
                .append("#{issn,jdbcType=VARCHAR},").append("#{periodic_no,jdbcType=VARCHAR},")
                .append("#{page,jdbcType=VARCHAR},").append("#{publisher,jdbcType=VARCHAR},")
                .append("#{level,jdbcType=VARCHAR},").append("#{org_id,jdbcType=VARCHAR},").append("#{creater_id,jdbcType=VARCHAR},")
                .append("#{creater_name,jdbcType=VARCHAR},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", tAcadeAchiveInfo.getId());
        params.put("pub_time", tAcadeAchiveInfo.getPubTime());
        params.put("acad_type", tAcadeAchiveInfo.getAcadType());
        params.put("acad_name", tAcadeAchiveInfo.getAcadName());
        params.put("summary", tAcadeAchiveInfo.getSummary());
        params.put("pub_name", tAcadeAchiveInfo.getPubName());
        params.put("issn", tAcadeAchiveInfo.getIssn());
        params.put("periodic_no", tAcadeAchiveInfo.getPeriodicNo());
        params.put("page", tAcadeAchiveInfo.getPage());
        params.put("publisher", tAcadeAchiveInfo.getPublisher());
        params.put("level", tAcadeAchiveInfo.getLevel());
        params.put("org_id", tAcadeAchiveInfo.getOrgId());
        params.put("creater_id", tAcadeAchiveInfo.getCreaterId());
        params.put("creater_name", tAcadeAchiveInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", tAcadeAchiveInfo.getUpdaterId());
        params.put("updater_name", tAcadeAchiveInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", tAcadeAchiveInfo.getIsValid());
        params.put("audit_state", tAcadeAchiveInfo.getAuditState());
        params.put("orignal_id", tAcadeAchiveInfo.getOrignalId());
        params.put("business_type_id", tAcadeAchiveInfo.getBusinessTypeId());
        params.put("primitive_id", tAcadeAchiveInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
